# See LICENSE file for copyright and license details.

include config.mk

SRC = fn85.c
OBJ = $(SRC:.c=.o)

LIB = libfn85.a
INC = fn85.h

PKG_STR = "\nIf this is a local install you may need to run:\n\t\
\"export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig\" \nto use this library.\n"

.PHONY: all install uninstall clean

all: $(LIB)

$(LIB): $(OBJ)
	@$(AR) -rcs $@ $(OBJ)

.c.o:
	@$(CC) $(CFLAGS) -c $<

fn85.3.gz: fn85.3
	@gzip -k fn85.3

install: $(LIB) $(INC) fn85.3.gz fn85.pc
	@echo @ install libfn85 to $(PREFIX)
	@mkdir -p $(PREFIX)/lib
	@cp $(LIB) $(PREFIX)/lib/
	@echo @ install fn85.h to $(PREFIX)
	@mkdir -p $(PREFIX)/include
	@cp $(INC) $(PREFIX)/include/
	@echo @ install fn85.3 to $(PREFIX)
	@mkdir -p $(PREFIX)/share/man/man3
	@cp fn85.3.gz $(PREFIX)/share/man/man3/
	@mandb -q -p
	@echo @ install fn85.pc to $(PREFIX)
	@printf $(PKG_STR)
	@mkdir -p $(PREFIX)/lib/pkgconfig
	@cp fn85.pc $(PREFIX)/lib/pkgconfig/

uninstall:
	@echo @ uninstall fn85 from $(PREFIX)
	@rm -f $(PREFIX)/lib/$(LIB)
	@rm -f $(PREFIX)/include/$(INC)
	@rm -f $(PREFIX)/share/man/man3/fn85.3.gz
	@rm -f $(PREFIX)/lib/pkgconfig/fn85.pc

clean:
	@rm -f $(LIB) $(OBJ) fn85.3.gz
